#include "unit.h"
Unit::Unit(int x, int y, int size,double HP,double maxHP):m_x(x),m_y(y),m_size(size),m_HP(HP),m_maxHP(maxHP){}
int Unit::get_x()		{	 return m_x;	 }
int Unit::get_y()		{	 return m_y;	 }
int Unit::get_size()	{	 return m_size;  }
double Unit::get_HP()		{	 return m_HP;	 }
double Unit::get_maxHP()	{	 return m_maxHP; }
int Unit::showHP()
{
    if (m_HP == 0)   return 0;
    double ratio = static_cast<double>(m_HP) / m_maxHP;
    if (ratio < 0.15) return 1;
    if (ratio < 0.25) return 2;
    if (ratio < 0.35) return 3;
    if (ratio < 0.45) return 4;
    if (ratio < 0.55) return 5;
    if (ratio < 0.65) return 6;
    if (ratio < 0.75) return 7;
    if (ratio < 0.85) return 8;
    if (ratio < 1.0) return 9;
    return 10;
}

void Unit::changeData(int x,int y,int size)
{
	m_x = x;
	m_y = y;
	m_size = size;
}
void Unit::changeHP(double now_HP)
{
	m_HP = now_HP;
}
